class CreateCategories < ActiveRecord::Migration
  def self.up
    create_table :categories do |t|
      t.string :name
      t.integer :parent_id

      t.timestamps
    end
    
    Category.create :name => "Clothing", :parent_id => nil
    Category.create :name => "Jewelry", :parent_id => nil
    Category.create :name => "Paintings", :parent_id => nil
    Category.create :name => "Instruments", :parent_id => nil
    Category.create :name => "Sculptures", :parent_id => nil
    Category.create :name => "Women", :parent_id => Category.find_by_name("Clothing")
    Category.create :name => "Men", :parent_id => Category.find_by_name("Clothing")
    Category.create :name => "Dresses", :parent_id => Category.find_by_name("Women").id
    Category.create :name => "Glass", :parent_id => Category.find_by_name("Jewelry").id
    Category.create :name => "Oil", :parent_id => Category.find_by_name("Paintings").id
    Category.create :name => "People", :parent_id => Category.find_by_name("Sculptures").id
    Category.create :name => "Percussions", :parent_id => Category.find_by_name("Instruments").id
  end

  def self.down
    drop_table :categories
  end
end
